    	$(function(){
    	
    		/*-----自动补全-----*/
    		//autocomplete插件选项			 
 			var option={
			 	minChars: 0,  
       			autoFill: true,   
        		matchContains: true,  
        		formatItem: function(data, i, total) {  
            		return "<I>"+data.name+"</I>";  
        		},  
        		formatMatch: function(data, i, total) {  
            		return data.name;  
        		},  
        		formatResult: function(data) {  
            		return data.name;  
        		}
			};				
			//调用ajax返回数据库数据，实现自动补全	 
			$.post("auto.action",{name:1},function(data){
					var item=eval("("+data+")");
			 		$("#model").autocomplete(item,option);
			});
			$.post("auto.action",{name:2},function(data){
					var is=eval("("+data+")");
			 		$("#region").autocomplete(is,option);
			});
			$.post("auto.action",{name:3},function(data){
					var is=eval("("+data+")");
			 		$("#city").autocomplete(is,option);
			});
			$.post("auto.action",{name:4},function(data){
					var is=eval("("+data+")");
			 		$("#venue_type").autocomplete(is,option);
			});
			/*-----自动补全-----*/
			
			$("#aisles_number,#unit").numeric({allow:"."});
			$("#aisles_number,#unit").poshytip({
				content: 'Enter a number',
				className: 'tip-yellowsimple',
				showOn: 'focus',
				alignTo: 'target',
				alignX: 'inner-left',
				offsetX: 0,
				offsetY: 5
			});
			
			/*-----输入验证-----*/
			//验证QBX Number是否已存在
			var checkValue=[true,true,true];
			function CheckQBXNumber(temp,i)
			{
				var content=$("#"+temp).val();
				if(content!=null&&content!="")
				{
					$.post("checkVM.action",{
						id:i,
						value:content
					},function(data){
						if(data=="error")
						{
							$("#f"+i).html("Lost connection with server");
							checkValue[i]=false;
						}
						else if(data=="false")
						{
							$("#f"+i).html("");
							checkValue[i]=true;
						}
						else
						{
							$("#f"+i).html("This machine has already exists");
							checkValue[i]=false;
						}
					});				
				}
			}
			
			$("#qbx_number").keyup(function(){CheckQBXNumber("qbx_number",0);});
			$("#alona_number").keyup(function(){CheckQBXNumber("alona_number",1);});
			$("#venue_code").keyup(function(){CheckQBXNumber("venue_code",2);});
			/*-----输入验证-----*/
						 		
    		//保存并继续
    		$("#save").click(function(){
    			//判断输入是否为空
    			var temp=true;
    			$("input").each(function(){
    				if($(this).val()==""||$(this).val()==undefined)
    				{
    					temp=false;
    					return;
    				}
    			}); 
    			if(!temp)
    				alert("All form files are required");
    			else if(checkValue[0]&&checkValue[1]&&checkValue[2])
    			{  			
    				//自动组织传递参数
    				var url="CreateAisles.jsp?"+$("form").serialize();
    				location.href=url;
    			}
    			else
    				alert("This machine has already exists");	
    				  			
    		});
    		
    	});